﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using DiscoveryLogic.Analytics.DataObjects.Measures;
using DiscoveryLogic.Analytics.DataObjects.Visuals;
using Size=System.Windows.Size;

namespace DiscoveryLogic.Analytics.DataObjects
{
    public abstract class EntityControlBase : UserControl
    {
        private VerticeState _State;
        /// <summary></summary>
        public VerticeState State
        {
            get
            {
                return this._State;
            }
            set
            {
                this._State = value;
            }
        }

        public EntityControlBase()
            : base()
        {
            this._State = VerticeState.Normal;
        }

        public abstract void SwitchableControl(BitmapImage imgSrc, bool selected);

        public abstract void SetDisabled(bool disabled);

        public abstract void SetHighlighted(bool highlighted);
        
        public abstract Size ImageSize { get; }

        public abstract void UpdateVisual();

        public bool ShowLabel(EntityBase entity, VerticeVisual vv, VerticeMeasure vm)
        {
            if (this._State == VerticeState.Selected)
                return true;

            if(vv.ShowLabelsForNames!=null && vv.ShowLabelsForNames.Count>0)
            {
                string entityName = entity.Name.ToLower();
                if(string.IsNullOrEmpty(entityName))
                    return false;
                foreach(string name in vv.ShowLabelsForNames)
                {
                    if(name.ToLower()==entityName)
                        return true;
                }
                return false;
            }
            else if(vv.ShowLabelsWhenDegreeAbove>0)
            {
                if(vm.Degree>=vv.ShowLabelsWhenDegreeAbove)
                    return true;
                else
                    return false;
            }
            else if(vv.ShowLabelAll)
                return true;
            else
                return false;
        }
    }
}
